package com.kh.springwebSocket.socket;

import com.kh.springwebSocket.config.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by crossice on 2017/5/13.
 */
@Controller
public class SocketController {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    @GetMapping("/sendNotice")
    //@SendTo("/client/showNotice")
    @ResponseBody
    public void showNotice(@RequestParam(required = false) String value) {

        System.out.println(SecurityUtils.getCurrentUserLogin());

        messagingTemplate.convertAndSendToUser("kong", "/tasks", value);

    }
}
